Why Less is More
$ git commit -m "Increase shared_buffers to 8GB
Reason: Memory upgrade from 16GB to 32GB
Tested: staging environment
Ticket: DBA-1234"
Clean • Simplify • Organize
# - Memory -
#shared_buffers = 128MB
#huge_pages = try
#max_prepared_transactions = 0
shared_buffers = 4GB
shared_buffers = 4GB
# postgresql.conf
work_mem = 16MB
# postgresql.auto.conf (via ALTER SYSTEM)
work_mem = 32MB
# Which one wins?
include 'conf.d/memory.conf'
include 'conf.d/connections.conf'
include 'conf.d/replication.conf'
include 'conf.d/logging.conf'
include 'conf.d/vacuum.conf'
include 'conf.d'
From Theory to Practice
# PostgreSQL 15 Production Config
# Server: db-prod-01
# Last updated: 2025-04-01
listen_addresses = '*'
ssl = on
shared_buffers = 8GB
work_mem = 128MB
maintenance_work_mem = 2GB
autovacuum_work_mem = 1GB
max_connections = 500
temp_file_limit = 1GB
archive_mode = on
archive_command = 'pgbackrest --stanza=prod archive-push %p'
random_page_cost = 1.5
effective_cache_size = 24GB
log_destination = 'csvlog'
logging_collector = on
log_directory = '/var/log/postgresql'
log_rotation_size = 1GB
log_min_duration_statement = 250ms
log_autovacuum_min_duration = 0
log_checkpoints = on
log_connections = on
log_disconnections = on
log_lock_waits = on
log_temp_files = 0
statement_timeout = 10min
idle_in_transaction_session_timeout = 30min
deadlock_timeout = 100ms
# PostgreSQL 15 Production Config
# Server: db-prod-01
# Last updated: 2025-04-01
include 'conf.d/memory.conf'
include 'conf.d/connections.conf'
include 'conf.d/replication.conf'
include 'conf.d/logging.conf'
# PostgreSQL Client Authentication Configuration File
# ===================================================
#
# TYPE DATABASE USER ADDRESS METHOD
# IPv4 local connections:
host all all 127.0.0.1/32 md5
# IPv6 local connections:
host all all ::1/128 md5
# Allow replication connections from localhost
host replication all 192.168.1.10/32 md5
host replication all ::1/128 md5
host marketing_db john 10.0.2.50/32 scram-sha-256
host marketing_db maria 10.0.2.50/32 scram-sha-256
host sales_db sales_user 192.168.1.10/32 md5
host sales_db sales_user 192.168.1.11/32 md5
host sales_db sales_user 192.168.1.12/32 md5
host marketing_db robert 10.0.2.50/32 scram-sha-256
host marketing_db sarah 10.0.2.50/32 scram-sha-256
host crm_db crm_user 192.168.1.20/32 md5
host crm_db crm_user 192.168.1.21/32 md5
host marketing_db david 10.0.2.50/32 scram-sha-256
# LOCAL ACCESS
local all postgres peer
host all all t127.0.0.1/32 scram-sha-256
host all all ::1/128 scram-sha-256
# APPLICATION SERVERS
host sales_db +sales_user 192.168.1.0/24 scram-sha-256
host crm_db +crm_user 192.168.1.0/24 scram-sha-256
host marketing_db +marketing_user 10.0.2.50/32 scram-sha-256
# REPLICATION
host replication all 10.0.0.0/24 scram-sha-256
Thank You!